import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    // 1.获取FlutterViewController(是应用程序的默认Controller)
       let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
       
       // 2.获取MethodChannel(方法通道)
       let batteryChannel = FlutterMethodChannel(name: "system_share_wx_muti_img",
                                                 binaryMessenger: controller.binaryMessenger)
       
       // 3.监听方法调用(会调用传入的回调函数)
       batteryChannel.setMethodCallHandler({
         [weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
         // 3.1.判断是否是getBatteryInfo的调用,告知Flutter端没有实现对应的方法
//         guard call.method == "getBatteryInfo" else {
//           result(FlutterMethodNotImplemented)
//
//           return
//         }
         print("img1")
        if(call.method == "sharemutiimg"){

            
//           let img = imgs[1]
            
            let a = (call.arguments)   as? [String : Any]
            let b = a!["imgs"] as? [String]
           print(b![0])
            
            
            self?.shareMutiImg();

        }
        
        
         // 3.2.如果调用的是getBatteryInfo的方法, 那么通过封装的另外一个方法实现回调
//         self?.receiveBatteryLevel(result: result)
        
       })
    
    
    
    
    
    
    
    
    
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
    
    
    func shareMutiImg(){
        
        let url:String = "weixin://"
          
        UIApplication.shared.openURL(NSURL(string: url) as! URL)
        
        
    }
}
